#include "cipher.h"

#include <stdio.h>
#include <string>
#include <list>

std::string Cipher::Normalize(const std::string& input)
{
	std::string output;

	for (int i = 0; i < input.length(); ++i)
	{
		if (input[i] >= 97 && input[i] <= 122)
		{
			output += input[i] - 32;
		}
		else if (input[i] >= 65 && input[i] <= 90)
		{
			output += input[i];
		} 
	}

	size_t length = output.length();

	if (0 != length % 5)
	{
		for (int i = 0; i < (5 - (length % 5)); ++i)
		{
			output += 'X';
		}
	}

	return output;
}

std::list<int> Cipher::Numberize(const std::string& input)
{
	std::list<int> output;

	for (int i = 0; i < input.length(); ++i)
	{
		if (input[i] < 65 || input[i] > 122)
		{
			continue;
		}

		output.push_back(input[i] - 64);
	}

	return output;
}
